#!/bin/bash   

# Install svn
echo "========== Install svn =========="
read -p "Proceed ? (y/n)" input
if [ "$input" = "y" ]; then
sudo apt-get update
sudo apt-get install subversion
fi

# Install dexen
echo "========== Install dexen =========="
read -p "Proceed ? (y/n)" input
if [ "$input" = "y" ]; then
cd /usr/local
sudo svn co https://dexen.googlecode.com/svn/dexen_project/trunk dexen
fi

# Install GLX libs
echo "========== Install GLX libs =========="
read -p "Proceed ? (y/n)" input
if [ "$input" = "y" ]; then
sudo add-apt-repository ppa:xorg-edgers/ppa 
sudo apt-get update
sudo apt-get install libgl1-mesa-swx11 
fi

# Install Houdini
echo "========== Install Houdini =========="
read -p "Proceed ? (y/n)" input
if [ "$input" = "y" ]; then
cd /usr/local
sudo wget ftp://ftp.sidefx.com/public/Houdini12.5/houdini-12.5.376-linux_x86_64_gcc4.4.tar.gz
sudo tar -xvzf houdini-12.5.376-linux_x86_64_gcc4.4.tar.gz
cd houdini-12.5.376-linux_x86_64_gcc4.4
sudo ./houdini.install
cd /usr/local/houdini
source houdini_setup;
fi

# Install Houdini libs
echo "========== Install Houdini libs =========="
read -p "Proceed ? (y/n)" input
if [ "$input" = "y" ]; then
cd /usr/local
sudo svn co https://dexen.googlecode.com/svn/houdini_libs houdini_libs
fi

# Install Houdini lics
echo "========== Install Hudini lics =========="
read -p "Proceed ? (y/n)" input
if [ "$input" = "y" ]; then
cd /usr/local
sudo svn co https://dexen.googlecode.com/svn/houdini_lics houdini_lics
sudo chmod 777 /usr/lib/sesi
fi

# Install mongoDB
echo "========== Install mongoDB =========="
read -p "Proceed ? (y/n)" input
if [ "$input" = "y" ]; then
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/10gen.list
sudo apt-get update
sudo apt-get install mongodb-10gen
fi

# Install python libs
echo "========== Install python libs =========="
read -p "Proceed ? (y/n)" input
if [ "$input" = "y" ]; then
sudo apt-get install python-shapely
sudo apt-get install python-mechanize
fi

# Install config files
echo "========== Install config files =========="
read -p "Proceed ? (y/n)" input
if [ "$input" = "y" ]; then
sudo rm /etc/environment
sudo svn co --force https://dexen.googlecode.com/svn/dexen_ec2/etc /etc
sudo chmod +x /etc/init/dex*.sh
sudo chmod +x /etc/init/reload.sh
fi

# Clean up
echo "========== Clean up =========="
read -p "Proceed ? (y/n)" input
if [ "$input" = "y" ]; then
cd /usr/local
sudo rm *.gz
sudo rm -rf houdini-12.5.376-linux_x86_64_gcc4.4
fi